package com.neuedu.hisadmin.service.impl;
//
//import com.neuedu.hisadmin.entity.Medicalcard;
//import com.neuedu.hisadmin.mapper.MedicalcardMapper;
//import com.neuedu.hisadmin.service.IMedicalcardService;
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
//import org.springframework.stereotype.Service;
//
//import java.util.List;
//
///**
// * <p>
// *  服务实现类
// * </p>
// *
// * @author jaun
// * @since 2025-07-05
// */
//@Service
//public class MedicalcardServiceImpl extends ServiceImpl<MedicalcardMapper, Medicalcard> implements IMedicalcardService {
//
//    @Override
//    public List<Medicalcard> listValidCards() {
//        return List.of();
//    }
//}

/*
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.neuedu.hisadmin.entity.Medicalcard;
import com.neuedu.hisadmin.mapper.MedicalcardMapper;
import com.neuedu.hisadmin.service.IMedicalcardService;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class MedicalcardServiceImpl extends ServiceImpl<MedicalcardMapper, Medicalcard> implements IMedicalcardService {
    @Override
   public List<Medicalcard> listValidCards() {
       return list(new LambdaQueryWrapper<Medicalcard>()
               .eq(Medicalcard::getDelMark, 1));
    }

    @Override
    public List<Medicalcard> searchByKeyword(String keyword) {
        // 构建动态查询条件：姓名或身份证号匹配，且 delMark=1
        return list(new LambdaQueryWrapper<Medicalcard>()
                .eq(Medicalcard::getDelMark, 1)
               .and(wrapper ->
                       wrapper.like(Medicalcard::getRealName, keyword)
                                .or()
                                .like(Medicalcard::getIdnumber, keyword)
               ));
    }
}*/


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.neuedu.hisadmin.entity.Medicalcard;
import com.neuedu.hisadmin.mapper.MedicalcardMapper;
import com.neuedu.hisadmin.service.IMedicalcardService;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class MedicalcardServiceImpl extends ServiceImpl<MedicalcardMapper, Medicalcard> implements IMedicalcardService {

    @Override
    public List<Medicalcard> listValidCards() {
        return list(new LambdaQueryWrapper<Medicalcard>()
                .eq(Medicalcard::getDelMark, 1));
    }

    @Override
    public List<Medicalcard> searchByKeyword(String keyword) {
        // 构建动态查询条件：姓名或身份证号匹配，且 delMark=1，同时指定要查询的字段
        return list(new LambdaQueryWrapper<Medicalcard>()
                .select(
                        Medicalcard::getId,
                        Medicalcard::getRealName,
                        Medicalcard::getGender,
                        Medicalcard::getIdnumber,
                        Medicalcard::getBirthdate,
                        Medicalcard::getPhone,
                        Medicalcard::getCardtype
                )
                .eq(Medicalcard::getDelMark, 1)
                .and(wrapper ->
                        wrapper.like(Medicalcard::getRealName, keyword)
                                .or()
                                .like(Medicalcard::getIdnumber, keyword)
                ));
    }
}